package JUC并发编程.三大特性.原子性.CAS保证原子性;

public class 可见性问题 {

    public static volatile boolean flag = true;

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            while(flag){
                // todo
            }
            System.out.println("t1线程结束");
        });
        t1.start();
        Thread.sleep(10);
        flag = false;
        System.out.println("主线程将flag改为 false = " + flag);
    }
}
